// class修饰符
// 公共public
/* class Animal {
    public name:string
    constructor(theName:string) {
        this.name = theName
    }
    public move(distanceInMeters: number){
        console.log(`${this.name} moved ${distanceInMeters}m.`);
    }
} */

// private 私有
/* class Animal {
    private name: string;
    constructor(theName: string) {
        this.name = theName
    }
} */
// new Animal("Cat").name //错误的， 只能在类里面访问

/* class Animal {
    private name:string;
    constructor(theName: string) {
        this.name = theName
    }
}
class Rhino extends Animal {
    constructor() {
        super("Rhino")
    }
}

class Employee {
    private name:string;
    constructor(theName: string) {
        this.name = theName;
    }
}

let animal = new Animal("Goat")
let rhino = new Rhino();
let employee = new Employee("Bob");

animal = rhino;
// animal = employee; 错误 */

// protected
// pretected成员在派生类中任然可以访问
/* class Person {
    protected name: string;
    constructor(name: string) {
        this.name = name
    }
}
class Employee extends Person {
    private department: string;
    constructor(name:string, deparment:string) {
        super(name)
        this.department = deparment
    }
    public getElevatorOitch() {
        return `hello, my name is ${this.name} and I work in ${this.department}.`
    }
}

let howard = new Employee('howard', 'sales')
console.log(howard.getElevatorOitch());
console.log(howard.name); // 错误 */

// readonly 修饰符
/* class Octopus {
    readonly name:string;
    readonly numerOfLegs:number = 8;
    constructor(theName:string) {
        this.name = theName;
    }
}
let dad = new Octopus("Man with the 8 strong legs");
dad.name = "haha " //错误 */

// 存取器
/* class Employee {
    fullName: string;
}

let employee = new Employee();
employee.fullName = "Bob Smith";
if (employee.fullName) {
    console.log(employee.fullName);
} */


/* let passcode = "secret passcode";

class Employee {
    private _fullName: string;

    get fullName(): string {
        return this._fullName;
    }

    set fullName(newName: string) {
        if (passcode && passcode == "secret passcode") {
            this._fullName = newName;
        }
        else {
            console.log("Error: Unauthorized update of employee!");
        }
    }
}

let employee = new Employee();
employee.fullName = "Bob Smith";
if (employee.fullName) {
    alert(employee.fullName);
} */
